package com.supcon.exchangedata.controller;

import com.supcon.exchangedata.pojo.entity.AjaxMessage;
import com.supcon.exchangedata.pojo.entity.oracle.StatistOtherParametersMonth;
import com.supcon.exchangedata.repository.slave1.SlaveOneStatistOtherParametersMonthRepository;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**   提供给外部使用
 * Created with IntelliJ IDEA.
 *
 * @Author: yangbin
 * @Date: 2022/06/28/9:21
 * @Description:
 */
@Controller("out_interface_data")
@RequestMapping
public class OutInterfaceController {
    @Resource
    private SlaveOneStatistOtherParametersMonthRepository slaveOneStatistOtherParametersMonthRepository;


    @GetMapping("water_meters")
    @ResponseBody
    public AjaxMessage NumberOfIntelligentWaterMeters(){
        List<StatistOtherParametersMonth> allByObjIdAndTypeOrderByMonthKeyDesc = slaveOneStatistOtherParametersMonthRepository.findAllByObjIdAndTypeAndInAvgValueIsNotNullOrderByMonthKeyDesc(2L, 20037L);
        return AjaxMessage.success(allByObjIdAndTypeOrderByMonthKeyDesc);
    }

    @GetMapping("water_meters_cover")
    @ResponseBody
    public AjaxMessage IntelligentWaterMetersCover(){
        List<StatistOtherParametersMonth> allByObjIdAndTypeOrderByMonthKeyDesc = slaveOneStatistOtherParametersMonthRepository.findAllByObjIdAndTypeAndInAvgValueIsNotNullOrderByMonthKeyDesc(2L, 20038L);
        return AjaxMessage.success(allByObjIdAndTypeOrderByMonthKeyDesc);
    }

}
